package com.sykj.bsc.zjj.service.Impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sykj.bsc.rwl.commons.ServerResponse;
import com.sykj.bsc.rwl.po.SysMenu;
import com.sykj.bsc.zjj.bean.Bis_shop_post;
import com.sykj.bsc.zjj.bean.Bis_shop_user;
import com.sykj.bsc.zjj.mapper.Bis_shop_userMapper1;
import com.sykj.bsc.zjj.service.Bis_shop_userService1;
import com.sykj.bsc.zn.controller.QtController;

/**
 * 前台
 * 员工管理
 * @author Lenovo G50-80
 *
 */
@Service
public class Bis_shop_userServiceImpl1 implements Bis_shop_userService1 {
	@Autowired
	private Bis_shop_userMapper1 bsum1;

	/**
	 * 查询所有
	 * Bis_shop_user
	 * 店铺用户信息表
	 */
	@Override
	public List<Map> selectBis_shop_user1(Bis_shop_user bis_shop_user) {
		return this.bsum1.selectBis_shop_user1(bis_shop_user);
	}

	/**
	 * 查询职位
	 * Bis_shop_post
	 * 店铺职位信息表
	 */
	@Override
	public List<Bis_shop_post> seListBis_shop_post1() {
		return this.bsum1.seListBis_shop_post1();
	}

	/**
	 * 根据ID查询
	 */
	@Override
	public Bis_shop_user findByIdBis_shop_user1(Bis_shop_user shop_user_id) {
		return this.bsum1.findByIdBis_shop_user1(shop_user_id);
	}

	
	public ServerResponse<Bis_shop_user> find_Bis_shop_user(String username, String password) {
		int resultCount=bsum1.findUserAccount(username);
		if(resultCount==0) {
			return ServerResponse.createByError("用户名不存在");
		}
		//todo 未调用方法
		Object data= QtController.Md5Encrypt(username, password);
		password=data.toString();
		Bis_shop_user buser=bsum1.find_Bis_shop_user1(username, password);
		if(buser!=null) {
			buser.setPassword("");
			return ServerResponse.createBySuccess("登录成功",buser);
		}
		return ServerResponse.createByError("密码错误");
	}

	@Override
	public List<SysMenu> findUserMenu(String post_code) {
		List<SysMenu> list = bsum1.find_Bis_shop_Post(post_code);
		return list;
	}
}
